package com.xxg.renrenproduct.dao;

import com.xxg.renrencommon.domain.dao.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * RenrenShopShopDao继承基类
 */
@Mapper
@Repository
public interface RenrenShopShopDao extends BaseMapper<RenrenShopShop, Integer> {
    @Select("SELECT id FROM renren_shop_shop WHERE user_id = #{userId,jdbcType=INTEGER} AND is_deleted = 0 LIMIT 1")
    Integer selectShopIdByUserId(Integer userId);

    @Select("SELECT id FROM renren_shop_shop WHERE user_id = #{userId,jdbcType=INTEGER} AND audit_status = 10 AND is_trial = 0 AND is_deleted = 0 LIMIT 1")
    Integer selectNormalShopIdByUserId(Integer userId);

    @Select("SELECT user_id FROM renren_shop_shop WHERE id = #{id,jdbcType=INTEGER}")
    Integer selectUserIdByPrimaryKey(Integer id);

    @Select({"<script>",
            "select id,user_id as userId,name,logo,is_deleted as isDeleted",
            "from renren_shop_shop where id in",
            "<foreach collection='ids' item='id' open='(' separator=',' close=')'>",
            "#{id}",
            "</foreach>",
            "</script>"})
    List<RenrenShopShop> selectByIds(@Param("ids") List<Integer> ids);
}